package com.danieldura.highrise.data
{
	import com.adobe.utils.DateUtil;
	
	public class User implements HighriseData
	{
		public var id:int;
		public var personId:int;
		public var name:String;
		public var createdAt:Date;
		public var updatedAt:Date;
		
		public function parse( data:XML ):void
		{
			id = data.id;
			personId = data["person-id"];
			name = data.name;
			createdAt = DateUtil.parseW3CDTF( data["created-at"] );
			updatedAt = DateUtil.parseW3CDTF( data["updated-at"] );
		}
		
		public function toXML():XML
		{
			var data:XML = new XML( <user /> );
			data.id = id;
			data["person-id"] = personId;
			data.name = name;
			return data;
		}
		
		public function toXMLString():String
		{
			return toXML().toXMLString();
		}		
		
	}
}

/*
<user>
  <id type="integer">1</id>
  <person-id type="integer">2</person-id>
  <name>david</name>
  <created-at type="datetime">2007-04-23T20:25:29Z</created-at>
  <updated-at type="datetime">2007-04-23T20:25:29Z</updated-at>
</user>
*/